<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        body > div {
            width: 1000px;
            border: 1px solid red;
            /*所有子元素浮动,自动识别的高度为0,后面的元素会顶上来,导致元素
            层叠的显示异常
            给元素添加overflow:hidden解决问题*/
            overflow: hidden;
        }

        div > div {
            width: 50px;
            height: 50px;
        }

        #d1 {
            background-color: red;
            float: left;
        }

        #d2 {
            background-color: green;
            float: left;
        }


        #d3 {
            background-color: blue;
            float: left;
        }

        div > ul {
            list-style-type: none;
            margin: 0;
            padding: 0;
            overflow: hidden;
        }

        li {
            display: inline;
            float: left;
            margin-right: 20px;
            text-align: center;
            width: 60px;
            height: 28px;
            background-color: #0aa1ed;
            border-radius: 3px;
        }

        a {
            color: white;
            text-decoration: none;
        }
    </style>
</head>
<body>
<div>
    <ul>
        <li><a href="">首页</a></li>
        <li><a href="">免费课</a></li>
        <li><a href="">直播课</a></li>
        <li><a href="">精品课</a></li>
    </ul>
</div>
<div>
    <div id="d1"></div>
    <div id="d2"></div>
    <div id="d3"></div>
</div>
</body>
</html>